package slipview.util.ldk.slipview

import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentPagerAdapter
import android.support.v7.app.AppCompatActivity
import android.util.Log
import kotlinx.android.synthetic.main.activity_slip_root_view.*
import ldk.util.slipview.SlipView

/**
 * Created by ldkxingzhe@163.com on 2017/6/20.
 */
class SlipRootViewActivity : AppCompatActivity() {
    val TAG = "SlipRootViewActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_slip_root_view)

        btn_test_click.setOnClickListener {
            Log.v(TAG, "测试按钮被点击")
            startActivity(Intent(this, SlipRootViewActivity::class.java))
        }

        view_pager.adapter = object : FragmentPagerAdapter(supportFragmentManager) {

            override fun getItem(position: Int): Fragment {
                return TestFragment()
            }

            override fun getCount(): Int {
                return 10
            }

        }

        fl_content.setOnClickListener {
            Log.v(TAG, "fl_content被点击")
            startActivity(Intent(this, DrawerLayoutActivity::class.java))
        }

        slip_root_view.previousActivity = {
            val application = applicationContext as LApplication
            application.applicationSingleTask.previousActivity()
        }
        vertical_slip_root_view.edge = SlipView.EDGE_TOP
    }

    override fun onSaveInstanceState(outState: Bundle?) {
        super.onSaveInstanceState(outState)
    }
}